home *** CD-ROM | disk | FTP | other *** search
/ Clickx 96 / Clickx 96.iso / software / tools / tool / xbmc-10.1.exe / addons / webinterface.default / js / Launcher.js < prev    next >
Encoding:
JavaScript  |  2011-03-08  |  3.4 KB  |  82 lines

  1. /*
  2.  *      Copyright (C) 2005-2010 Team XBMC
  3.  *      http://www.xbmc.org
  4.  *
  5.  *  This Program is free software; you can redistribute it and/or modify
  6.  *  it under the terms of the GNU General Public License as published by
  7.  *  the Free Software Foundation; either version 2, or (at your option)
  8.  *  any later version.
  9.  *
  10.  *  This Program is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13.  *  GNU General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU General Public License
  16.  *  along with XBMC; see the file COPYING.  If not, write to
  17.  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *  http://www.gnu.org/copyleft/gpl.html
  19.  *
  20.  */
  21.  
  22. /* This launcher is based on the scriptaculous.js launch script */
  23.  
  24. // Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
  25. // 
  26. // Permission is hereby granted, free of charge, to any person obtaining
  27. // a copy of this software and associated documentation files (the
  28. // "Software"), to deal in the Software without restriction, including
  29. // without limitation the rights to use, copy, modify, merge, publish,
  30. // distribute, sublicense, and/or sell copies of the Software, and to
  31. // permit persons to whom the Software is furnished to do so, subject to
  32. // the following conditions:
  33. // 
  34. // The above copyright notice and this permission notice shall be
  35. // included in all copies or substantial portions of the Software.
  36. //
  37. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  38. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  39. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  40. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  41. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  42. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  43. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  44. //
  45. // For details, see the script.aculo.us web site: http://script.aculo.us/
  46.  
  47. var DEBUG_MODE = true; /* Set to false to enable cached javascript */
  48.  
  49. var Launcher = {
  50.     VERSION: '1.0.0',
  51.     REQUIRED_JQUERY: '1.4.2',
  52.     load: function(libraryName) {
  53.         document.write('<script type="text/javascript" src="' + libraryName + '?' + (DEBUG_MODE ? this.randomValue() : this.VERSION) + '"><\/script>');
  54.     },
  55.     init: function() {
  56.         function convertVersionString(versionString) {
  57.             var v = versionString.replace(/_.*|\./g, '');
  58.             v = parseInt(v + (v.length == 4 ? '' : '0'));
  59.             return versionString.indexOf('_') > -1 ? v-1 : v;
  60.         }
  61.  
  62.         if(!jQuery || (convertVersionString(jQuery.fn.jquery) < convertVersionString(Launcher.REQUIRED_JQUERY)))
  63.             throw("XBMC Web Interface requires the jQuery JavaScript framework >= " + Launcher.REQUIRED_JQUERY);
  64.  
  65.         var js = /Launcher\.js(\?.*)?$/;
  66.         $('html').find('script[src]').each(
  67.             function(i, s) { 
  68.                 if (s.src.match(js)) {
  69.                     var path = s.src.replace(js, ''),
  70.                     includes = s.src.match(/\?.*load=([a-z,]*)/);
  71.                     $.each((includes ? includes[1] : 'jquery.lazyload,iscroll-min,Core,MediaLibrary,NowPlayingManager').split(','), function(i, include) { 
  72.                         Launcher.load(path + include + '.js') 
  73.                     });
  74.                 }
  75.             });
  76.     },
  77.     randomValue: function() {
  78.         return Math.random();
  79.     }
  80. }
  81.  
  82. Launcher.init();